<?php

namespace app\partner\controller;

use think\Db;

class Article extends Authorized
{

    public function index()
    {
        return $this->fetch();
    }


    public function getList()
    {
        $get_data=$this->request->get();
        $post_data = $this->request->post();

        $page = $get_data['page'];
        $limit = $get_data['limit'];

        $keywords = input('keywords');
        $where=[];


        if (!empty($keywords)){
            $where['article.title']=['like','%'.$keywords.'%'];
        }



        $count=Db::table('article')->where($where)->count();
        $rows=Db::table('article')
            ->where($where)
            ->order('sort desc,created_at desc')
            ->page($page, $limit)
            ->select();
        return json(['code' =>0,'count' =>$count,'msg' =>'','data'=>$rows]);
    }

    public function show()
    {

        $article=Db::table('article')->where('id' , input('id'))->find();
        $this->assign('article', $article);
       return $this->fetch();
    }

}